package com.tanhua.server.controller;

import com.tanhua.model.mongo.PeachBlossomAudio;
import com.tanhua.model.vo.PeachBlossomVo;
import com.tanhua.server.service.PeachblossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

//桃花传音Controller
@RestController
@RequestMapping("/peachblossom")
public class PeachblossomController {


    @Autowired
    private PeachblossomService peachblossomService;

    /*
     *  桃花传音-发送语音（学生实战）
     *    请求方式和请求链接 : POST
     *    请求参数: body soundFile
     *    返回值: 无
     * */
    @PostMapping
    public ResponseEntity peachblossom(@RequestBody MultipartFile soundFile ) throws IOException {

        peachblossomService.savePeachblossom(soundFile);
        return ResponseEntity.ok(null);

    }


    /*
     *  桃花传音-接收语音（学生实战）
     *    请求方式和请求链接 : GET
     *    请求参数:
     *    返回值: peachblossomVo
     */
    @GetMapping
    public ResponseEntity peachblossom(){
    PeachBlossomVo vo =peachblossomService.findPeachblossom();

        return ResponseEntity.ok(vo);
    }
}
